/**
 * 
 */
package br.ufpe.cin.plebeia.gui;

import java.awt.Rectangle;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import br.ufpe.cin.plebeia.model.Perfume;
import br.ufpe.cin.plebeia.persistence.hibernateDao.HibernateBasicDao;

/**
 * @author bruno
 *
 */
public class InserirPerfume extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JButton cancelar = null;

	private JButton inserir = null;

	private JLabel perfumeLabel = null;

	private JTextField perfumeField = null;

	/**
	 * This method initializes cancelar	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getCancelar() {
		if (cancelar == null) {
			cancelar = new JButton();
			cancelar.setBounds(new Rectangle(29, 45, 118, 28));
			cancelar.setText("Cancelar");
		}
		return cancelar;
	}

	/**
	 * This method initializes inserir	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getInserir() {
		if (inserir == null) {
			inserir = new JButton();
			inserir.setBounds(new Rectangle(242, 47, 120, 30));
			inserir.setText("Inserir");
			inserir.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					HibernateBasicDao<Perfume> dao = new HibernateBasicDao<Perfume>(Perfume.class);
					
					Perfume perfume = new Perfume();
					perfume.setNome(perfumeField.getText());
					
					dao.save(perfume);
					
				}
			});
		}
		return inserir;
	}

	/**
	 * This method initializes perfumeField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getPerfumeField() {
		if (perfumeField == null) {
			perfumeField = new JTextField();
			perfumeField.setBounds(new Rectangle(150, 14, 213, 20));
		}
		return perfumeField;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				InserirPerfume thisClass = new InserirPerfume();
				thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				thisClass.setVisible(true);
			}
		});
	}

	/**
	 * This is the default constructor
	 */
	public InserirPerfume() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(400, 118);
		this.setContentPane(getJContentPane());
		this.setTitle("JFrame");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			perfumeLabel = new JLabel();
			perfumeLabel.setBounds(new Rectangle(30, 16, 106, 15));
			perfumeLabel.setText("nome do perfume:");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getCancelar(), null);
			jContentPane.add(getInserir(), null);
			jContentPane.add(perfumeLabel, null);
			jContentPane.add(getPerfumeField(), null);
		}
		return jContentPane;
	}

}  //  @jve:decl-index=0:visual-constraint="34,10"
